var a = getApp(), e = (a.require("utils/util.js"), a.require("utils/api.js")), t = a.require("utils/enums.js"), n = 0, o = -1, r = [];

Page({
    data: {
        errandTypes: t.ErrandTypes,
        typeIndex: o,
        lastPage: !1,
        model: r
    },
    onLoad: function(a) {
        var e = [];
        e.push({
            Name: "外卖跑腿",
            Value: 2048
        });
        for (var n in t.ErrandTypes) e.push(t.ErrandTypes[n]);
        this.setData({
            errandTypes: e
        }), this.loadData(a);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        n = 0, this.loadData(null, wx.stopPullDownRefresh, wx.stopPullDownRefresh);
    },
    onReachBottom: function() {
        this.data.lastPage || this.loadData({
            pageIndex: ++n
        });
    },
    onShareAppMessage: function() {},
    loadData: function(t, n, o) {
        var s = this;
        e.orderErrandList(t, function(e) {
            if (t && t.pageIndex) for (var o in e) r.push(e[o]); else r = e;
            s.setData({
                lastPage: e.length < a.pageSize,
                model: r
            }), n && n();
        }, function() {
            o && o();
        });
    },
    onCategoryItemTap: function(a) {
        var e = this;
        o = a.currentTarget.dataset.index;
        var t = e.data.errandTypes, n = o < 0 ? 0 : t[o].Value;
        this.loadData({
            stype: n
        }), e.setData({
            typeIndex: o
        });
    },
    onItemSubmitTap: function(a) {
        var e = a.currentTarget.dataset.index, t = r[e];
        wx.navigateTo({
            url: "info?id=" + t.Id + (2 != t.Status || t.IsForbiddenAccept ? "" : "&submit=true")
        });
    }
});